<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象简写</title>
</head>
<body>
<p>
    对象中的属性名和需要赋值的变量名一致时，可以省略属性名
</p>
<script>
    let name = "王贺";
    let age = 24;

    //对象用户的传统方式，属性名:变量名
    let user = {name:name,age:age};
    console.log(user.name,user.age);

    //对象简写
    let user2 = {name,age};
    console.log(user2,"user2");
</script>
</body>
</html>